from fastapi import Depends,Request
from app.db.redis import sys_cache
from redis.asyncio import Redis
from app.core.Response import success


async def my_redis(request: Request):
    # 连接池放在requests
    value =await  request.app.state.cache.get("today")
    return success(msg="my_redis",data=[value])


async def redis_deppends(today:int,cache:Redis=Depends(sys_cache)):
    # 连接池放在依赖注入
    # await cache
    await cache.set(name="today",value=today)

    return success(msg=f"今天是{today}日子",data=[])
